package com.wlz.consumer.consumer;

import com.wlz.api.DemoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;

/**
 *  本地存根
 * @author wlz
 * @date 2022-07-12  10:50 下午
 */
@Slf4j
@EnableAutoConfiguration
public class StubDubboConsumerDemo {

//    @Reference(version = "timeout", timeout = 1000, stub = "true")
    @Reference(version = "timeout", timeout = 1000, stub = "com.tuling.DemoServiceStub")
    private DemoService demoService;

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(StubDubboConsumerDemo.class, args);

        DemoService demoService = context.getBean(DemoService.class);

        // 服务调用超时时间为1秒，默认为3秒
        // 如果这1秒内没有收到服务结果，则会报错
        String result = demoService.sayHello("wlz stub ...");
        log.info("result:  {}", result);
    }
}
